package tech.aistar.day02.redirect;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * 本类用来演示: 入口
 *
 * @author: success
 * @date: 2022/3/22 9:06 上午
 */
@WebServlet("/redirect/from")
public class FromRedirect extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //故意想要在页面输出内容 - 到时候观察是否输出内容了
        //结论 - 没有出现...
        PrintWriter out = resp.getWriter();;
        out.println("redirect...");

        //为了证明确实这个servlet执行了
        System.out.println("console-redirect...");

        //跳转
        //重定向到另外一个servlet - /redirect/to
        resp.sendRedirect("/st/redirect/to");
    }
}
